<template>
  <a-spin :spinning="confirmLoading">
    <a-form-model ref="form" :model="models" :rules="validatorRules">
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tone" required label="选择语气">
        <a-radio-group name="tenantStatus" v-model="models.tone">
          <a-radio value="有说服力">有说服力</a-radio> 
          <a-radio value="正式得体">正式得体</a-radio>
          <a-radio value="专业">专业</a-radio>
          <a-radio value="幽默">幽默</a-radio>
          <a-radio value="热情">热情</a-radio>
        </a-radio-group>
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productIntroduction" required label="公司/产品名称">
        <a-textarea
          :rows="3"
          v-model="models.productIntroduction"
          placeholder="美国艾比瑞尔化妆品"
        />
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productCompanyName" required label="产品介绍">
        <a-textarea
          :rows="5"
          v-model="models.productCompanyName"
          placeholder="天然有机化妆品，温和安全"
        />
      </a-form-model-item>
    </a-form-model>
  </a-spin>
</template>

<script>
export default {
  name: 'CorePoints',
  components: {},
  props: {
    model: {
      type: Object,
      default: {},
    },
  },

  data() {
    return {
      addIconShow: true,
      shoppIngIcon: '',
      models: this.model,
      confirmLoading: false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      validatorRules: {
          tone: [
            { required: true, message: '请选择语气' },
          ],
          productIntroduction: [
            { required: true, message: '请输入公司/产品名称' },
            { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' }
          ],
          productCompanyName: [
            { required: true, message: '请输入产品介绍' },
            { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' }
          ],
      },
    }
  },

  created() {},
  computed: {
    models1() {
      return this.models
    },
  },
  watch: {
    models1: {
      handler(newVal, oldVal) {
        // console.log('newVal + oldVal',newVal, oldVal)
        // console.log('handler',newVal,  this.model)
        if (!newVal.tone) {
          //只需判断一个即可
          this.$set(this.model, "tone", "有说服力");
          
        }
      },
      deep: true,
      immediate: true,
    },
  },
  updated() {},
  mounted() {
    this.$nextTick(function () {
      console.log('11111111111111111', this.models)
    })
  },
  methods: {
    generatedBtnProp() {
      let obj = {
        tone: this.models.tone,
        productIntroduction: this.models.productIntroduction,
        productCompanyName: this.models.productCompanyName,
      }
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit('appApiAsk', 1, obj)
        } else {
          this.$emit('appApiAsk', 2, obj)
        }
      })
    },
  },
}
</script>

<style lang="less">
</style>